package com.example.binpacking.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.binpacking.model.QuestionnaireItem;
import com.example.binpacking.model.QuestionnaireName;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;

@Mapper
public interface QuestionnaireItemMapper extends BaseMapper<QuestionnaireItem> {
    @Select("SELECT a.*,(select name from tbl_dictionary_questionnaire b where b.id=a.parentid) as questionnairename from tbl_dictionary_item a where a.parentid=#{parentid} and a.isdeleted=#{isdeleted}\n" +
            "            order by a.orderid;")
    Page<QuestionnaireItem> selectByDeletedAndParent(Page<QuestionnaireItem> page, @Param("isdeleted") BigDecimal isdeleted,@Param("parentid") BigDecimal parentid);

    @Update("update tbl_dictionary_item set name= #{name} where id= #{id}")
    int updateNameById(@Param("id")BigDecimal id,@Param("name")String name);

    @Update("update tbl_dictionary_item set isdeleted= #{isdeleted} where id= #{id}")
    int updateDeletedById(@Param("id")BigDecimal id,@Param("isdeleted")BigDecimal isdeleted);
}
